package Polymorphism;

/*
* ClassCastException:类型转换异常
*
* 在引用数据类型的强转中, [实际类型] 和 [目标类型] 不匹配就会此异常
*
* */
import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入： 1.国内订单   2.国外订单");
        int choice = sc.nextInt();
        orderService orderService = null;


        switch (choice){
            case 1:
                orderService = new orderServicelmpl();
                break;
                //创建国内订单系统
//                orderServicelmpl orderService = new orderServicelmpl();
//                orderService.create();
//                orderService.findOne();
//                orderService.findList();
//                orderService.cancel();
//                orderService.finish();
//                orderService.paid();

            case 2:
                orderService = new OverderServicelmpl();
                break;
                //创建国外订单系统：
//                OverderServicelmpl overderServicelmpl = new OverderServicelmpl();
//                overderServicelmpl.create();
//                overderServicelmpl.findOne();
//                overderServicelmpl.findList();
//                overderServicelmpl.cancel();
//                overderServicelmpl.finish();
//                overderServicelmpl.paid();
        }
    //判断左边的引用，是否是右边的数据类型
        if (orderService instanceof OverderServicelmpl){
            OverderServicelmpl osi = (OverderServicelmpl)orderService;

            osi.check();
        }

                orderService.create();
                orderService.findOne();
                orderService.findList();
                orderService.cancel();
                orderService.finish();
                orderService.paid();

    }
}
